package com.demo.animation;

import android.graphics.Canvas;
import android.view.ViewGroup;
/**
 * analysis miui's workspace specific effect...
 * @author 209
 * 2011-8-30
 */
public abstract class DesktopEffect{
	//the viewGroup width
	protected float mViewWidth;
	//current sub view left edge
	protected float mCurrentSubViewLeft;
	//viewGroup's scrollX..
	protected float mViewScrollX;
	
	/**
	 * 
	 * @param view   the viewGroup include sub view
	 * @param canvas current sub view's canvas
	 * @param index  current sub view id
	 */
	public abstract void drawScreen(ViewGroup view, Canvas canvas, int index);
	
	protected boolean initData(ViewGroup view, int index){
		mViewWidth = view.getWidth();
		mCurrentSubViewLeft = mViewWidth * index;
		mViewScrollX = view.getScrollX();
		//i think it always return ture!!!
	    if(mCurrentSubViewLeft > mViewScrollX + mViewWidth 
	       || mCurrentSubViewLeft + mViewWidth < mViewScrollX) { 
            return false;
        } 
	    return true;
	}
}